<?php
namespace app\controllers;
use Yii;
use yii\filters\AccessControl;
use yii\web\Controller;
Class Week3Controller extends Controller
{
     
  public $layout = false;
  public function actionRegis()
  {

    return $this->render('regis');

  }
  public function actionAjax()
  {
    $idcard = yii::$app->request->post('idcard');
    $name = yii::$app->request->post('name');
    $tel = yii::$app->request->post('tel');
    $email = yii::$app->request->post('email');
    $sql = "SELECT * FROM marathon_registration where name = '$name'";
    $res = yii::$app->db->createCommand($sql)->queryOne();
    if($res)
    {
    	echo json_encode('false');
    }
    else
    {
    $sql = "INSERT INTO marathon_registration VALUES(NULL,'$idcard','$name','$tel','$email','1')";
    $data = yii::$app->db->createCommand($sql)->execute();
    if($data)
    {
    	echo json_encode('11');
    }
    else
    {
      echo json_encode('22');
    }	


  }


    }



     //列表展示
    public function actionList()
    {
      $search = yii::$app->request->post('search')?yii::$app->request->post('search'):'';
      $sql = "SELECT * FROM marathon_registration WHERE name like '%$search%' ";
      $data = yii::$app->db->createCommand($sql)->queryAll();
      if($data)
      {
      	return $this->render('list',['data'=>$data]);
      }	

    }
    
      //审核页面展示
    public function actionUpdate()
    {
    
    return $this->render('update');


    }


}